// createStore,store实例函数
import { createStore } from 'vuex'
// 导入数据模块
import user from './modules/user'
import cart from './modules/cart'
// 导入vuex持久化数据插件方法
import createPersistedstate from 'vuex-persistedstate'
// 导入cookie存储工具
// import Cookies from 'js-cookie'

export default createStore({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    user,
    cart
  },
  getters: {},
  // 配置vuex插件
  plugins: [
    createPersistedstate({
      key: 'rabbit-key',
      // 要持久化的数据
      paths: ['user', 'cart']
      // storage: {
      //   getItem: key => Cookies.get(key),
      //   setItem: (key, value) => Cookies.set(key, value, { expires: 3, secure: true }),
      //   removeItem: key => Cookies.remove(key)
      // }
    })
  ]
})
